;(function($,_helper,_server){
    $(function(){
        $(document).on("pageInit", function(e, pageId, page) {
            console.log(pageId);
            if(pageId == "page_register") {
                $("#sex").picker({
                    toolbarTemplate: '<header class="bar bar-nav">\
                                      <button class="button button-link pull-right close-picker">确定</button>\
                                      <h1 class="title">请选择称谓</h1>\
                                      </header>',
                    cols: [
                        {
                            textAlign: 'center',
                            values: ['男','女']
                        }
                    ]
                });
            }else if(pageId == "page_re_success") {

            }else if(pageId == "page_account") {

            }else if(pageId == "page_account_info") {
                //性别
                $("#sex").picker({
                    toolbarTemplate: '<header class="bar bar-nav">\
                                      <button class="button button-link pull-right close-picker">确定</button>\
                                      <h1 class="title">请选择称谓</h1>\
                                      </header>',
                    cols: [
                        {
                            textAlign: 'center',
                            values: ['男','女']
                        }
                    ]
                });

                //住址
                $("#address").cityPicker({
                    toolbarTemplate: '<header class="bar bar-nav">\
                    <button class="button button-link pull-right close-picker">确定</button>\
                    <h1 class="title">选择家庭地址</h1>\
                    </header>'
                });
            }else{

            }
        });

        //轮播图
        $(".swiper-container").swiper({
            speed: 400,
            spaceBetween: 10
        });

        //发送验证码
        var sendVerificationCode = false;
        var countDownTime = 60;
        $("#sendBtn").on("click",function(e){
            e.stopPropagation();
            if(sendVerificationCode) return false;
            countDownTimeFun();
            function countDownTimeFun(){
                setTimeout(function(){
                    countDownTime--;
                    if(countDownTime>0){
                        $("#sendBtn").html(countDownTime+"秒");
                        countDownTimeFun();
                    }else{
                        $("#sendBtn").html("获取验证码");
                        sendVerificationCode=false;
                    }
                },1000);

            }
        });

        //完成注册
        $("#submitBtn").on("click",function(e){
            e.stopPropagation();
            var $mobile = $("#mobile");
            if(!$mobile.val()){
                $.alert('请输入手机号码！',function(){
                    $mobile.focus();
                });
                return false;
            }else if(!new RegExp(_helper.regExp().mobile).test($mobile.val())){
                $.alert('请输入正确的手机号码！',function(){
                    $mobile.focus();
                });
                return false;
            }
            var $verification_code = $("#verification_code");
            if(!$verification_code.val()){
                $.alert('请输入验证码！',function(){
                    $verification_code.focus();
                });
                return false;
            }
            $("#registerFore").submit();
        });



        $.init();
    });
})(Zepto,_helper,_server);